$(document).ready(function () {    
    var ipcRenderer = require('electron').ipcRenderer;
    var sharedObject = require('electron').remote.getGlobal('sharedObject');
    var baseUrl = sharedObject.baseUrl;
    var isBig = true;//窗口放大还原标示
    $.ajax({
        url: "http://localhost:8080/GeoModeling/LoadUserServlet",
        type: "get",
        async: false,
        success: function (data) {
            if (data == "") {
                $(".nav_login").show();
                $(".nav_signup").show();
                $(".nav_hello").hide();
                $(".nav_exit").hide();
            } else {
                var user = JSON.parse(data);
                $(".nav_login").hide();
                $(".nav_signup").hide();
                $(".nav_hello").empty();
                $(".nav_hello").append("<a title='" + user.uid + "'><strong>" + user.uname + "</strong></a>");
                $(".nav_hello").show();
                $(".nav_exit").show();
            }
        }
    });

    $(document).on("click", ".nav_exit", function () {
        $.ajax({
            url: "http://localhost:8080/GeoModeling/LoginOutServlet",
            type: "get",
            success: function (data) {
                window.location.href = baseUrl+"\\tool\\login.html";
            },
            error: function (data) {
                alert('error');
            }
        });
    });

    $(document).on("click",".win_min",function(){
        ipcRenderer.send('window-min');
    });

    $(document).on("click",".win_max",function(){
        if(isBig){
            ipcRenderer.send('window-max');
        }else{
            ipcRenderer.send('window-orignal');
        }
        isBig=!isBig;
    });

    $(document).on("click",".win_close",function(){
        ipcRenderer.send('window-close');
    });
});
